package com.htwy.ext;

import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.activerecord.Model;
import java.io.InputStream;

public abstract class BaseMappingKit implements IMappingKit {

    protected void addSqlTemplate(ActiveRecordPlugin arp,String classPath, String... fileNames){
        for(String fileName:fileNames) {
            InputStream is = getClass().getResourceAsStream("/" + classPath.replace(".", "/") + "/" + fileName);
            if (is != null) {
                arp.addSqlTemplate(new InputSteamStringSource(fileName, is));
            }
        }
    }

    protected void addMapping(ActiveRecordPlugin arp, String tableName, String idStr, Class<? extends Model<?>> modelClass){
        arp.addMapping(tableName, idStr, modelClass);
    }

}
